package top.huntwolf.admin.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.huntwolf.admin.dao.bookStatusDao;
import top.huntwolf.admin.pojo.book.NewBook;
import top.huntwolf.admin.pojo.bookStatus;

import java.util.List;


@Service
@Transactional
public class bookStatusService {

    @Autowired
    private bookStatusDao statusDao;


    public PageInfo<NewBook> searchBookInfoByCMS(int pageNum, int pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<NewBook> NewBooks = statusDao.selectBookInfo();
        PageInfo<NewBook> pageInfo = new PageInfo<>(NewBooks);
        return pageInfo;
    }

    public PageInfo<NewBook> searchBookInfoByIsbn(String isbn,int pageNum, int pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<NewBook> NewBooks = statusDao.selectBookInfoByIsbn(isbn);
        PageInfo<NewBook> pageInfo = new PageInfo<>(NewBooks);
        return pageInfo;
    }

    public PageInfo<NewBook> searchBookInfoByTitle(String title,int pageNum, int pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<NewBook> NewBooks = statusDao.selectBookInfoByTitle(title);
        PageInfo<NewBook> pageInfo = new PageInfo<>(NewBooks);
        return pageInfo;
    }

    public void addStatus(bookStatus bookStatus){
        statusDao.addStatus(bookStatus);
    }

    public void deleteStatus(String id){
        statusDao.deleteStatus(id);
    }

    public void updateStatus(List<bookStatus> bookStatuses){
        statusDao.updateStatus(bookStatuses);
    }


}
